{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "单面\n",
      "双面\n"
     ]
    }
   ],
   "source": [
    "!docker run -itd --name redis -p 6379:6379 redis:latest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: http://mirrors.aliyun.com/pypi/simple/\n",
      "Collecting redis\n",
      "  Downloading http://mirrors.aliyun.com/pypi/packages/df/b2/dfdc17f701f7b587f6c89c2b9b6b5978c87a8a785555efc810b064c875de/redis-5.0.0-py3-none-any.whl (250 kB)\n",
      "     ---------------------------------------- 0.0/250.1 kB ? eta -:--:--\n",
      "     - -------------------------------------- 10.2/250.1 kB ? eta -:--:--\n",
      "     ------ ------------------------------ 41.0/250.1 kB 653.6 kB/s eta 0:00:01\n",
      "     ---------- -------------------------- 71.7/250.1 kB 653.6 kB/s eta 0:00:01\n",
      "     ------------- ----------------------- 92.2/250.1 kB 655.4 kB/s eta 0:00:01\n",
      "     ----------------- ------------------ 122.9/250.1 kB 599.1 kB/s eta 0:00:01\n",
      "     ---------------------- ------------- 153.6/250.1 kB 654.6 kB/s eta 0:00:01\n",
      "     ------------------------- ---------- 174.1/250.1 kB 615.9 kB/s eta 0:00:01\n",
      "     ----------------------------- ------ 204.8/250.1 kB 591.4 kB/s eta 0:00:01\n",
      "     --------------------------------- -- 235.5/250.1 kB 600.7 kB/s eta 0:00:01\n",
      "     ------------------------------------ 250.1/250.1 kB 613.4 kB/s eta 0:00:00\n",
      "Installing collected packages: redis\n",
      "Successfully installed redis-5.0.0\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip install redis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import redis\n",
    "\n",
    "host = '127.0.0.1'\n",
    "port = 6379\n",
    "password = None\n",
    "db = None\n",
    "conn = redis.Redis(host,port,password,db)\n",
    "\n",
    "conn.set('key','value')\n",
    "conn.get('key')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
